package com.ruoyi.common.core.domain.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseIdEntity;
import com.ruoyi.common.utils.StringUtils;
import lombok.Data;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;

import java.util.Date;

/**
 * 车辆信息对象 w_vehicle
 * 
 * @author lynn
 * @date 2023-08-01
 */
@Data
@ApiModel(value = "WVehicle", description = "车辆信息对象")
public class WVehicle extends BaseIdEntity
{
    private static final long serialVersionUID = 1L;

    /** id */
    @ApiModelProperty("id")
    private String id;

    /** 用户ID */
    @Excel(name = "用户ID")
    @ApiModelProperty("用户ID")
    private String memberId;

    @TableField(exist = false)
    @Excel(name = "用户昵称")
    @ApiModelProperty("用户昵称")
    private String nickName;

    @TableField(exist = false)
    @Excel(name = "真实姓名")
    @ApiModelProperty("真实姓名")
    private String realName;

    @TableField(exist = false)
    @Excel(name = "电话号码")
    @ApiModelProperty("电话号码")
    private String userName;

    @TableField(exist = false)
    @Excel(name = "充电卡号")
    @ApiModelProperty("充电卡号")
    private String cardNo;
    @TableField(exist = false)
    private Integer memberType;
    @TableField(exist = false)
    private Integer vipType;

    @TableField(exist = false)
    @Excel(name = "点位名称")
    @ApiModelProperty("点位名称")
    private String areaName;
    @TableField(exist = false)
    private String areaId;

    /** 充电类型ID */
    @Excel(name = "充电类型ID")
    @ApiModelProperty("充电类型ID")
    private String vehicleChargeTypeId;

    @TableField(exist = false)
    @Excel(name = "充电类型")
    @ApiModelProperty("充电类型")
    private String vehicleChargeTypeValue;

    /** 非充电类型ID */
    @Excel(name = "非充电类型ID")
    @ApiModelProperty("非充电类型ID")
    private String vehicleNonChargeTypeId;

    @TableField(exist = false)
    @Excel(name = "非充电类型")
    @ApiModelProperty("非充电类型")
    private String vehicleNonChargeTypeValue;

    /** 车辆照片地址 */
    @Excel(name = "车辆照片地址")
    @ApiModelProperty("车辆照片地址")
    private String vehicleImgUrl;

    /** 单元号 */
    @ApiModelProperty("单元号")
    private String buildingNo;

    /** 车辆品牌 */
    @Excel(name = "车辆品牌")
    @ApiModelProperty("车辆品牌")
    private String vehicleBrand;

    /** 车牌号 */
    @Excel(name = "车牌号")
    @ApiModelProperty("车牌号")
    private String vehicleNumber;

    /** 备注 */
    @Excel(name = "备注")
    @ApiModelProperty("备注")
    private String remark;

    /** 创建者 */
    @TableField(fill = FieldFill.INSERT)
    @ApiModelProperty("创建者")
    private String createBy;

    /** 创建时间 */
    @ApiModelProperty("创建时间")
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /** 更新者 */
    @TableField(fill = FieldFill.UPDATE)
    @ApiModelProperty("更新者")
    private String updateBy;

    /** 更新时间 */
    @ApiModelProperty("更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;


    public <T> QueryWrapper<T> queryWrapper(){
        QueryWrapper<T> wrapper=new QueryWrapper<>();

        wrapper.like(StringUtils.isNotEmpty(id),"v.id" , id);
        wrapper.like(StringUtils.isNotEmpty(memberId),"v.member_id" , memberId);
        wrapper.like(StringUtils.isNotEmpty(vehicleChargeTypeId),"v.vehicle_charge_type_id" , vehicleChargeTypeId);
        wrapper.like(StringUtils.isNotEmpty(vehicleNonChargeTypeId),"v.vehicle_non_charge_type_id" , vehicleNonChargeTypeId);
        wrapper.like(StringUtils.isNotEmpty(vehicleImgUrl),"v.vehicle_img_url" , vehicleImgUrl);
        wrapper.like(StringUtils.isNotEmpty(buildingNo),"v.building_no" , buildingNo);
        wrapper.like(StringUtils.isNotEmpty(vehicleBrand),"v.vehicle_brand" , vehicleBrand);
        wrapper.like(StringUtils.isNotEmpty(vehicleNumber),"v.vehicle_number" , vehicleNumber);
        wrapper.like(StringUtils.isNotEmpty(vehicleNumber),"v.vehicle_number" , vehicleNumber);
        wrapper.like(StringUtils.isNotEmpty(areaId),"a.id" , areaId);
        wrapper.and(StringUtils.isNotEmpty(getKeyWord()),v -> {
            v.like("m.user_name", getKeyWord());
            v.or().like("m.nick_name", getKeyWord());
            v.or().like("m.real_name", getKeyWord());
        });
        wrapper.orderByDesc("v.create_time");
        return wrapper;
    }

}
